package models.common.entity;

import java.util.Date;
import java.util.Random;

import javax.persistence.Entity;
import javax.persistence.Transient;

import models.common.entity.t_recharge_user.Status;

import play.db.jpa.Model;

import common.constants.ConfConst;
import common.constants.Constants;
import common.enums.IsUse;
import common.enums.Target;
import common.utils.Security;

/**
 * 企业红黑名单实体
 *
 * @author liangqiongfeng
 * @createDate 2018年05月09日
 */
@Entity
public class t_reddish_black extends Model {
	
	/** 更新时间 */
	public Date time;
	
	/**
	 * 企业全称
	 */
	public String company_full_name;
	
	/**
	 * 是否为红名单 3 ；是否为黑名单 4
	 */
	public int type;
	
	public ReddishBlack getType() {
		
		ReddishBlack type = ReddishBlack.getEnum(this.type);
		
		return type;
	}

	public void setStatus(ReddishBlack type) {
		this.type = type.code;
	}

	/**
	 * 状态枚举
	 * 
	 * @description
	 *
	 * @author ChenZhipeng
	 * @createDate 2015年12月21日
	 */
	public enum ReddishBlack {

		/** 3:红名单 */
		REDDISH(3, "红名单企业"),


		/** 4-黑名单 */
		BLACK(4, "黑名单企业");

		public int code;
		public String value;

		private ReddishBlack(int code, String value) {
			this.code = code;
			this.value = value;
		}

		public static ReddishBlack getEnum(int code) {
			ReddishBlack[] reddishblack = ReddishBlack.values();
			for (ReddishBlack stat : reddishblack) {
				if (stat.code == code) {

					return stat;
				}
			}

			return null;
		}
	}
	
	
	/**加密ID*/
	@Transient
	public String sign;

	public String getSign() {
		
		return Security.addSign(this.id, Constants.BID_ID_SIGN, ConfConst.ENCRYPTION_KEY_DES);
	}
}
